﻿@{
    ViewBag.Title = "VIEW_AccountRecharge";
    Layout = "~/Views/Shared/MyAccount.cshtml";
}
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script>
    function Reset()
    {
        $(":input").each(function ()
        {
            $(this).val("")
        })
    }
    function Blurfun() {
            $.ajax({
                url: "/MyAccount/TestBankCard",
                type: "post",
                data: {
                    BankCard: $("#UserBankCard").val()
                },
                success: function (mes)
                {
                    if (mes == 0)
                    {
                        swal("失败",mes,"Error")
                        $("#SBankCard").html("✘与绑定银行卡不符")
                        $("#SBankCard").css("color","red")
                    }
                    else
                    {
                        $("#SBankCard").html("✔")
                        $("#SBankCard").css("color", "green")
                    }
                }
            })
    }

    function FunMoney()
    {
        if ($("#RechargeMoney").val() == "") {
            $("#Smoney").html("✘请输入充值金额")
            $("#Smoney").css("color", "green")
        }
        else {
            $("#Smoney").html("✔")
            $("#Smoney").css("color", "green")
        }
    }
    function ForPay()
    {
        $.ajax({
            url: "/MyAccount/TestPayPwd",
            type: "post",
            data: {
                Paypwd: $("#PayPwd").val(),
                Money: $("#RechargeMoney").val(),
                PhonePwd: $("#PhonePwd").val()
            }, success: function (mes)
            {
                if (mes==0) {
                    $("#paypwd").html("✘支付密码不正确")
                    $("#paypwd").css("color", "red")
                }
                else
                {
                    $("#paypwd").html("")
                    $("#Testpay").html("✔支付成功")
                    $("#Testpay").css("color", "green")
                    location.href = '/MyAccount/MyAccountIndex'
                }
            }
        })
    }
    function GetPhonePwd()
    {
        $.ajax({
            url:"/MyAccount/GetPhonePwd",
            type:"post",
            success:function(mes)
            {
                if (mes != 0)
                {
                    $("#PhonePwd").val(mes)
                    var btn = $("#GetPhonepwd");
                    var count = 60;
                    var resend = setInterval(function(){
                        count--;
                        if (count > 0){
                            btn.val(count+"秒后重获取");
                            $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
                        }else {
                            clearInterval(resend);
                            btn.val("获取验证码").removeAttr('disabled style');
                        }
                    }, 1000);
                    btn.attr('disabled',true).css('cursor','not-allowed');
                }
                else
                {
                    ///跳转到完善信息
                    location.href = '/Myaccount/PerfectPhone'
                }
            }
        })
    }
</script>
<table class="table" width="600" height="200">
    <tr>
        <td width="140">充值金额:</td>
        <td width="200">
            <input id="RechargeMoney" onblur="FunMoney()" type="text" size="25" value=""  maxlength="14" onkeyup='this.value=this.value.replace(/\D/gi,"")'>
        </td>
        <td width="260">
            <span id="Smoney"></span>
        </td>
    </tr>
    <tr>
        <td>请输入绑定银行卡</td>
        <td><input type="text" onblur="Blurfun()"  id="UserBankCard" value="" size="25" maxlength="19" onkeyup='this.value = this.value.replace(/\D/gi, "")' /></td>
        <td>
            <span id="SBankCard"></span>
        </td>
    </tr>
    <tr>
        <td>
            请输入手机验证码
        </td>
        <td><input type="text" onblur="TestPhonepwd()" id="PhonePwd" value=""  size="8"  maxlength="6"/>
        <input type="button" onclick="GetPhonePwd()" id="GetPhonepwd" value="获取验证码"  /></td>
        <td>
            <span id="Sphone"></span>
        </td>
    </tr>
    <tr>
        <td>请输入支付密码</td>
        <td><input type="password" id="PayPwd" value="" size="20" maxlength="6" onkeyup='this.value=this.value.replace(/\D/gi,"")' /></td>
        <td>
            <span id="paypwd"></span>
        </td>
    </tr>
    <tr>
        <td colspan="3">
            <span id="Testpay"></span>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center">
            <button name="name" value="" onclick="ForPay()" class="btn" style="background-color:#518eba">支付</button>
            &nbsp;&nbsp;
            <button name="name" value="" class="btn" style="background-color:#518eba" onclick="Reset()">取消</button>
        </td>
        <td>

        </td>
    </tr>
</table>
